package com.bsoft.gol.editor.controller;


import hcn.util.BaseResponse;
import com.bsoft.gol.editor.editor.request.ExamItemRequest;
import com.bsoft.gol.editor.editor.request.ExamreportRequest;
import com.bsoft.gol.editor.editor.request.LabreportRequest;
import com.bsoft.gol.editor.editor.request.UsageRequest;
import com.bsoft.gol.editor.editor.response.ExamItemResponse;
import com.bsoft.gol.editor.editor.response.ExamreportResponse;
import com.bsoft.gol.editor.editor.response.LabreportResponse;
import com.bsoft.gol.editor.editor.response.UsageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bsoft.gol.editor.service.EditorDictApi;
import com.bsoft.gol.editor.service.EditorHisModuleService;

import java.util.List;

/**
 * @author lxy
 * @date 2019/6/18
 */
@Controller
@RequestMapping(value = "/his/")
public class EditorHisModuleController {

    @Autowired
    private EditorHisModuleService editorHisModuleService;

    @Autowired
    private EditorDictApi editorDictApi;

    @RequestMapping("/labreport")
    @ResponseBody
    public BaseResponse<List<LabreportResponse>> labreport(@RequestBody LabreportRequest req) {
        return editorHisModuleService.labreport(req);
    }

    @RequestMapping("/examreport")
    @ResponseBody
    public BaseResponse<List<ExamreportResponse>> examreport(@RequestBody ExamreportRequest req) {
        return editorHisModuleService.examreport(req);
    }

    @RequestMapping("/usage")
    @ResponseBody
    public BaseResponse<List<UsageResponse>> usage(@RequestBody UsageRequest req) {
        return editorHisModuleService.usage(req);
    }

    @RequestMapping("/examImport")
    @ResponseBody
    public BaseResponse<String> examImport(@RequestBody ExamItemRequest req) {
        BaseResponse<String> response = new BaseResponse<>();
        BaseResponse<List<ExamItemResponse>> listBaseResponse = editorHisModuleService.examImport(req);

        if (listBaseResponse != null && listBaseResponse.getCode() == 200) {
            editorDictApi.saveExamItem(listBaseResponse.getData());
        }

        return response;
    }

}
